package com.lancer.springboot.service;


import com.lancer.springboot.domain.StudentRepository;
import com.lancer.springboot.domain.Students;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {
    @Resource
    StudentRepository studentDao;
    @Override
    public Students insertStudent(Students students) {
        return studentDao.save(students);
    }

    @Override
    public Students updateStudent(Students students) {
        return studentDao.save(students);
    }

    @Override
    public void deleteStudent(Long id) {
        studentDao.deleteById(id);
    }

    @Override
    public Students findStudentById(Long id) {
        return studentDao.findById(id).orElse(null);
    }

    @Override
    public List<Students> getAllStudents() {
        return studentDao.findAll();
    }
}
